package com.nescafe.nescafepromo.entity;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;

public class TotalPoints extends NPEntity {

	public static final String TOTAL_POINTS_FIELD = "totalPoints";

	private long totalPoints = 0;
	private Key parent = null;

	private Participant ownerParticipant = null;

	public TotalPoints(Key parent) {
		this.parent = parent;
	}

	public TotalPoints(Entity entity) {
		this.parent = entity.getParent();
		this.totalPoints = (Long) entity.getProperty(TOTAL_POINTS_FIELD);
	}

	public long getTotalPonts() {
		return totalPoints;
	}

	public void setTotalPonts(long totalPonts) {
		this.totalPoints = totalPonts;
	}

	public Key getParent() {
		return parent;
	}

	public void setOwnerParticipant(Participant ownerParticipant) {
		this.ownerParticipant = ownerParticipant;
	}

	public Participant getOwnerParticipant() {
		return ownerParticipant;
	}

	@Override
	public Entity toEntity() {
		Entity e = new Entity(EntityType.TOTAL_POINTS.getKind(), parent.getName(), parent);
		e.setProperty(TOTAL_POINTS_FIELD, totalPoints);
		return e;
	}

}
